#include "expression.h"

expression::expression(int expr_id, const char *op_name, const char *op_type,
                       int *inputs, int num_inputs)
    : expr_id_(expr_id), op_name_(op_name), op_type_(op_type), 
    inputs_(inputs, inputs + num_inputs) {}

//给当前expression中的tensor赋值
void expression::add_op_param_double(const char *key, double value) {

  // result_wb[key] = tensor(value);

  const char *w = "weight"; 
  const char *b = "bias"; 
  const char *k = "kernel_size";
  const char *s = "stride";
  const char *i = "in_channels";
  const char *o = "out_channels";

  if((*key) == (*w)|| (*key) == (*b) ){
     result_wb[key] = tensor(value);
  }else if ((*key) == (*k)|| (*key) == (*s)||(*key) == (*i)||(*key) == (*o)){
    ker_and_str[key] = value;
  }else{
   result_ = tensor(value);
  }
}

void expression::add_op_param_ndarray(const char *key, int dim, size_t shape[],
                                       double data[]) {

  //result_wb[key] = tensor(dim, shape, data);


  const char *w = "weight"; 
  const char *b = "bias"; 
  // const char *k = "kernel_size";
  // const char *s = "stride";


  if((*key) == (*w)|| (*key) == (*b) ){
    result_wb[key] = tensor(dim, shape, data);
  }else{
    result_ = tensor(dim, shape, data);
  }
                                      
}
